
//
//  MSMacrosMethods.h
//  ZXDemo
//
//  Created by 马胜 on 2017/5/11.
//  Copyright © 2017年 SnailMS. All rights reserved.
//

#ifndef MSMacrosMethods_h
#define MSMacrosMethods_h

//打印
#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DLog(...)
#endif

// 是否空对象
#define IS_NULL_CLASS(OBJECT) [OBJECT isKindOfClass:[NSNull class]]

//
#define SET_VIEW_LAYER(setView,radius, bWidth, bColor) { \
setView.layer.masksToBounds = YES;\
setView.layer.cornerRadius = radius;\
if(!bColor){\
setView.layer.borderColor = BORDER_COLOR;\
}else{\
setView.layer.borderColor = bColor.CGColor;\
}\
setView.layer.borderWidth = bWidth;\
}\

#define ALERT(TITLE, MESSAGE) { \
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:TITLE message:MESSAGE preferredStyle:UIAlertControllerStyleAlert];\
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { \
[alertController dismissViewControllerAnimated:YES completion:nil];  \
}];\
[alertController addAction:okAction];\
[self presentViewController:alertController animated:YES completion:nil];\
}

#define MS_ALERT(TITLE, MESSAGE) { \
msAlertView *alerView = [[msAlertView alloc] initWithTitle:TITLE \
                                                   content:MESSAGE \
                                            titleAlignment:MSAlertViewTitleAlignmentCenter \
                                                      type:MSAlertViewTypeNormal \
                                                textAction:^(id data, BOOL isOK) { \
                                                }]; \
[alerView show]; \
}


#define REMOVE_CHILD_VIEW(SView) { \
for (UIView *view in SView.subviews) { \
[view removeFromSuperview]; \
} \
}

#define SET_DOWN_LINEVIEW(View, color) {\
UIView *lineView = [UIView new];\
lineView.backgroundColor = color;\
[View addSubview:lineView];\
[lineView mas_makeConstraints:^(MASConstraintMaker *make) {\
make.top.equalTo(View.mas_bottom);\
make.left.equalTo(View.mas_left);\
make.right.equalTo(View.mas_right);\
make.height.mas_equalTo(0.5);\
}];\
}

#define SET_RIGHT_LINEVIEW(View, color) {\
UIView *lineView = [UIView new];\
lineView.backgroundColor = color;\
[View addSubview:lineView];\
[lineView mas_makeConstraints:^(MASConstraintMaker *make) {\
make.top.equalTo(View.mas_top);\
make.bottom.equalTo(View.mas_bottom);\
make.left.equalTo(View.mas_right);\
make.width.mas_equalTo(1);\
}];\
}

#endif /* MSMacrosMethods_h */
